
package com.joysuch.wwyt.datadump.biz.convertor;

import cn.zlg.common.datadump.annotation.DataDumpField;
import cn.zlg.common.datadump.convertor.FieldValueConvert;
import org.springframework.stereotype.Component;

@Component
public class StringToIntegerConvertor implements FieldValueConvert<String, Integer> {

    @Override
    public Integer convert(Object bean, String value, DataDumpField dataField) {
        if(value == null) {
            return null;
        }
        try {
           return Integer.parseInt(value);
        } catch (Exception e) {
            throw  new IllegalArgumentException(value +"不是有效的整数");
        }
    }

}
